<?php
	$uri = $_SERVER['REQUEST_URI'];
	$uri_var = explode('/', $uri);
	
	$count = count($uri_var);
	$dot = "";
	
	if($uri_var[1] == "mvz-admin" || $uri_var[1] == "mvz-config")
	{
		for($i=0; $i<$count-2; $i++)
		{
			$dot = $dot."../";
		}
	}
	
	$string_path_begin = "mvz-config/";
	
	function LoadConfig($num, $type, $path, $dot)
	{
		$string = "config_".$type."_".$num; ${$string} = $dot.$path; 
		if(is_file(${$string}))
		{
			include(${$string});
		}
		else
		{
			throw new Exception("Cannot load ".ucfirst($type)." Configuration ".$num);
		}
	}
	
	if(!file_exists($dot.$_SERVER['REQUEST_URI']) && count($uri_var) < 2)
	{
		include($_SERVER['DOCUMENT_ROOT']."/source/global/other/php/404.php");
		die();
	}
	else
	{
		try
		{
			$type = "start";
		
			$num = 1; $path = $string_path_begin."global_con.php";
			LoadConfig($num, $type, $path, $dot);
			
			$num = 2; $path = $string_path_begin."connection/con_open.php";
			LoadConfig($num, $type, $path, $dot);
			
			$num = 3; $path = $string_path_begin."function_global.php";
			LoadConfig($num, $type, $path, $dot);
				
			$num = 4; $path = $string_path_begin."global.php";
			LoadConfig($num, $type, $path, $dot);
			
			$num = 5; $path = $string_path_begin."function.php";
			LoadConfig($num, $type, $path, $dot);
			
			$num = 6; $path = $string_path_begin."global_var.php";
			LoadConfig($num, $type, $path, $dot);
			
			$num = 7; $path = $string_path_begin."function_check_db.php";
			LoadConfig($num, $type, $path, $dot);
			
			$num = 8; $path = $string_path_begin."function_check_table.php";
			LoadConfig($num, $type, $path, $dot);
			
			$num = 9; $path = $string_path_begin."global_cms_version.php";
			LoadConfig($num, $type, $path, $dot);
			
			$num = 10; $path = $string_path_begin."global_ga.php";
			LoadConfig($num, $type, $path, $dot);
			
			$num = 11; $path = $string_path_begin."function_upload_image.php";
			LoadConfig($num, $type, $path, $dot);
			
			$num = 12; $path = $string_path_begin."function_upload_file.php";
			LoadConfig($num, $type, $path, $dot);
			
			$num = 13; $path = $string_path_begin."function_upload_logo.php";
			LoadConfig($num, $type, $path, $dot);
		}
		catch(Exception $ex)
		{
			echo "Oooops...<br />";
			echo "This page doesn't exist or some other horrible error has occurred.<br />";
			echo "<a href='javascript:history.back()'>Go Back</a>";
			die();
			//echo "Error : ",  $ex->getMessage(), "\n";
		}
	}
?>